*** Settings ***
Documentation               通过Redfish修改account组件的LoginInterface的属性值
Resource                    ../../test_function/redfish/redfish.robot
Resource                    ../../test_function/resource.robot
Library                     RequestsLibrary
Library                     Collections
Library                     String
Suite Setup                 Create Redfish_PATCH Session
Suite Teardown              Delete All Sessions

*** Variables ***
${ACCOUNT_ID}               2
${INPUT_URI}                /AccountService/Accounts/${ACCOUNT_ID}
${ETAG}                     ${EMPTY}

*** Test Cases ***
Modify Account Login Interface
    [Documentation]    通过Redfish修改Account内容
    [Tags]    Modify_Account_Login_Interface
    # patch方法需要ETag
    Get User ETag

    # 搭建headers
    ${headers}=    Create Dictionary
    ...    Content-Type=application/json
    ...    X-Auth-Token=${AUTH_TOKEN}
    ...    If-Match=${ETAG}

    # 修改属性内容--{body}
    ${login_interface}=    Create List    Redfish    Web
    ${openubmc_dict}=    Create Dictionary    LoginInterface=${login_interface}
    ${oem_dict}=    Create Dictionary    openUBMC=${openubmc_dict}
    ${payload}=    Create Dictionary    Oem=${oem_dict}

    ${rsp}=    PATCH On Session    redfish_patch
    ...    ${INPUT_URI}
    ...    json=${payload}
    ...    headers=${headers}

    # 验证响应状态码
    Should Be Equal As Strings    ${rsp.status_code}    ${SUCCESS_CODE}
    ...    msg=修改请求失败, 状态码:${rsp.status_code}

    # 验证返回的LoginInterface值
    ${login_interface}=    Get From Dictionary    ${rsp.json()["Oem"]["openUBMC"]}    LoginInterface
    ${expected_interface}=    Create List    Redfish    Web
    Lists Should Be Equal    ${login_interface}    ${expected_interface}
